<?php
exit;
$dbhost = '47.110.131.55';
$dbuser = 'root';
$dbpwd  ='sxy7788123456';
$dbName ='race';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {}

/*
 * 查询重复数据
select name from u3_c1 group by name having count(name) > 1
 */

$table='u3_zz';

echo $table,'....user table';
echo "<br /><br />";

$sql="select phone from ".$table." where ischong is NULL group by phone having count(phone) > 1";
echo $sql;


$query=$mysqli->query($sql);

while ($getUser=$query->fetch_assoc()){
    var_dump($getUser);
    echo "<br /><br />";
    
    
    $sql="select * from ".$table." where phone='".$getUser['phone']."'  order by fen desc  limit 0,2 ";
    $queryChong=$mysqli->query($sql);
    $getArr=array();
    $id=0;
    while ($getChong=$queryChong->fetch_assoc()){
        $getArr[]=$getChong;
        echo "<br />";
        echo "<a href='delete-user.php?id=".$getChong['id']."&table=".$table."'>delete</a> &nbsp;&nbsp;";
        echo $getChong['fen'],"---";
        echo $getChong['name'],"---",$getChong['phone'],"---",$getChong['idcard'];
        echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        echo $getChong['school'],"---",$getChong['openid'];
        echo "<br />";
        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='fix-user.php?id=".$getChong['id']."&table=".$table."'>do---fix</a> &nbsp;&nbsp;";
        
        echo "<br /><br />";
        $id=$getChong['id'];
    }
    if($getArr[0]['name'] == $getArr[1]['name'] && $getArr[0]['school'] == $getArr[1]['school']){
        echo "<span style='color:red;'>";
        echo "the same&nbsp;&nbsp;", $id;
        echo '</span>';
        echo "<br /><br />";
        $sql="update ".$table." set  ischong=1 where id=".$id."  ";
        echo $sql;
        $query=$mysqli->query($sql);
        
    }else{
        
        echo 'has on diff';
        echo "<br /><br />";
        $sql="update ".$table." set  ischong=9 where id=".$id."  ";
        echo $sql;
        $query=$mysqli->query($sql);
    }
    
     
    
    
    echo "<br /><br /><br /><br /><br /><br />";
    foreach($getArr as $v){
       var_dump($v);
        echo "<br /><br /><br />";
    }
    
    
    
    
    $mysqli->close();
    
    $stop=12;
    if(1 == $stop){
        exit;
    }

    echo '<script>
window.setTimeout(function(){
	location.reload();
},400);
</script>';
    
    exit;
}

$mysqli->close();

?>
<?php if (true == $has){ ?>

<?php } ?>


